//
//  PaperBoardInformationCell.m
//  ForestPack
//
//  Created by 骆锴 on 2018/7/24.
//  Copyright © 2018年 郑洲. All rights reserved.
//

#import "PaperBoardInformationCell.h"
#import "PaperBoardDetialModel.h"

@interface PaperBoardInformationCell ()

@property(nonatomic, strong) UILabel *title;
@property(nonatomic, strong) UILabel *price;

@end

@implementation PaperBoardInformationCell

+ (PaperBoardInformationCell *)cellWithTableView:(UITableView *)tableView andIndexPath:(NSIndexPath *)indexPath{
    static NSString *cellID = @"PaperBoardInformationCell";
    PaperBoardInformationCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
    if (cell == nil) {
        cell = [[PaperBoardInformationCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
        cell.backgroundColor = [UIColor whiteColor];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        [cell createSubView];
    }
    return cell;
}

-(void)createSubView{
    _title = [[UILabel alloc] initWithFrame:CGRectMake(ScreenX375(13), ScreenX375(15), ScreenX375(80), ScreenX375(14))];
    _title.text = @"选择箱型:";
    _title.font = Kfont(14);
    _title.textColor = REXADECIMALCOLOR(@"#333333");
    _title.textAlignment = NSTextAlignmentLeft;
    [self addSubview:_title];
    
    
    _price = [[UILabel alloc] initWithFrame:CGRectMake(ScreenX375(200), ScreenX375(16), ScreenX375(163), ScreenX375(14))];
    NSString *pricetext = [[NSString alloc] init];
    _price.text = @"0.00元/m²";
    pricetext = _price.text;
    _price.textColor = REXADECIMALCOLOR(@"#333333");
    _price.font = Kfont(13);
    _price.textAlignment = NSTextAlignmentRight;
    [self addSubview:_price];
    
    UILabel *line = [[UILabel alloc] initWithFrame:CGRectMake(ScreenX375(13), ScreenX375(43), ScreenX375(349), ScreenX375(1))];
    UIColor *color = [UIColor colorWithPatternImage:[UIImage imageNamed:@"虚线"]];
    [line setBackgroundColor:color];
    [self addSubview:line];
    
}

-(void)settitletext:(NSString *)titletext{
    _title.text = titletext;
}

-(void)setpricetext:(NSString *)pricetext{
    NSArray *number = @[@"0",@"1",@"2",@"3",@"4",@"5",@"6",@"7",@"8",@"9"];
    NSMutableAttributedString *attributeString = [[NSMutableAttributedString alloc]
                                                  initWithString:pricetext];
    for (int i = 0; i < pricetext.length; i ++) {
        NSString *a = [pricetext substringWithRange:NSMakeRange(i, 1)];
        if ([number containsObject:a]) {
            [attributeString setAttributes:@{NSForegroundColorAttributeName:ThemeColor,NSFontAttributeName:Kfont(13),NSUnderlineStyleAttributeName:[NSNumber numberWithInteger:NSUnderlineStyleNone]} range:NSMakeRange(i, 1)];
        }
    }
    _price.attributedText = attributeString;
}

- (void)initWithModel:(PaperBoardDetialModel *)model{
    _price.text = model.store;
}

@end
